<template>
    <view class="menu-card">
        <view class="header-box">
            <view class="title">{{ title }}</view>
            <view>
                <slot name="right"></slot>
            </view>
        </view>
        <view class="menu-grid">
            <view class="menu-item" v-for="(item,index) in dataList" :key="index" @tap="toPage(item)">
                <up-icon name="red-packet-fill" size="38"></up-icon>
                <view class="text">{{ item.label }}</view>
            </view>
        </view>
    </view>
</template>
<script setup>
const props = defineProps({
    dataList: {
        type: Array,
        default: () => []
    },
    title: {
        type: String,
        default: ""
    },
    deliveryMethod: {
        type: String,
        default: ""
    },
    source: {
        type: String,
        default: ""
    }
})

const toPage = (e) => {
    if (props.source === 'order') {
        const data = {
            status: e.value,
            delivery_method: props.deliveryMethod
        }
        qly.page.open('/pages/my/order/index', data)
    } else {
        qly.page.open(e.router)
    }
}
</script>
<style scoped lang="scss">
.menu-card {
    padding: 32rpx;
    background-color: #fff;
    margin-top: 18rpx;
    
    .header-box {
        display: flex;
        justify-content: space-between;
        align-items: center;
        
        .title {
            font-weight: bold;
            font-size: 32rpx;
        }
    }
    
    .menu-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 12rpx;
        margin-top: 18rpx;
        
        .menu-item {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            margin-top: 16rpx;
            
            .text {
                width: 100%;
                text-align: center;
                font-size: 24rpx;
                color: #303133;
            }
        }
    }
}
</style>
